
from kafka import KafkaProducer

#1、创建生产者

producer = KafkaProducer(bootstrap_servers='master:9092')

#2、生产数据
producer.send('shujia', b'hello world')
producer.flush()

#、关闭连接
producer.close()